<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${message("admin.ad.edit")} - </title>
<link href="${base}/resource/admin/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/resource/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resource/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resource/admin/editor/kindeditor.js"></script>
<script type="text/javascript" src="${base}/resource/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resource/admin/js/input.js"></script>
<script type="text/javascript" src="${base}/resource/admin/datePicker/WdatePicker.js"></script>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
	var $type = $("#type");
	var $contentTr = $("#contentTr");
	var $pathTr = $("#pathTr");
	var $path = $("#path");
	var $browserButton = $("#browserButton");

	
	[@flash_message /]

    $browserButton.browser();


	// “类型”修改
	$type.change(function() {
		if ($type.val() == "text") {
			$contentTr.show();
		} else {
			$contentTr.hide();
		}
	});

	// 表单验证
	$inputForm.validate({
		rules: {
			title: "required",
			adPositionId: "required",
			path: "required",
			order: "digits"
		}
	});

    $("select[name='universityId']").change(function(){
        var opt=$(this).find("option:selected").text();
        $("input[name='universityName']").val(opt);
    });
	
});
</script>
</head>
<body>
	<div class="path">
		<a href="/common/index">首页</a> &raquo; 编辑
	</div>
	<form id="inputForm" action="update.jhtml" method="post">
		<input type="hidden" name="id" value="${ad.id}" />
		<table class="input">
            <tr>
                <th>
                    广告位:
                </th>
                <td>
                    <select name="adPositionId" class="text">
					[#list adPositions as adPosition]
                        <option value="${adPosition.id}"[#if adPosition == ad.adPosition] selected="selected"[/#if]>${adPosition.name} [${adPosition.width} × ${adPosition.height}]</option>
					[/#list]
                    </select>
                </td>
            </tr>
			<tr>
				<th>
					<span class="requiredField">*</span>标题:
				</th>
				<td>
					<input type="text" name="title" class="text" value="${ad.title}" maxlength="200" />
				</td>
			</tr>
			<tr>
				<th>
					类型:
				</th>
				<td>
					<select id="type" name="type" class="text">
						[#list types as type]
							<option value="${type}"[#if type == ad.type] selected="selected"[/#if]>${message(type)}</option>
						[/#list]
					</select>
				</td>
			</tr>

			<tr id="contentTr"[#if ad.type != "text"] class="hidden"[/#if]>
				<th>
					内容:
				</th>
				<td>
					<textarea id="editor" name="content" class="editor" style="width: 100%;">${ad.content?html}</textarea>
				</td>
			</tr>
			<tr id="pathTr"[#if ad.type == "text"] [/#if]>
				<th>
					<span class="requiredField">*</span>地址:
				</th>
				<td>
					<span class="fieldSet">
						<input type="text" id="path" name="path" class="text" value="${ad.path}" maxlength="200"/>
						<input type="button" id="browserButton" class="button" value="选择" />
                        <span style="color: #cc0000;">当类型为图片时：图片路径、当类型为文本时：背景路径</span>
					</span>
				</td>
			</tr>
			<tr>
				<th>
					起始时间:
				</th>
				<td>
					<input type="text" id="beginDate" name="beginDate" class="text Wdate" value="[#if ad.beginDate??]${ad.beginDate?string("yyyy-MM-dd HH:mm:ss")}[/#if]" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', maxDate: '#F{$dp.$D(\'endDate\')}'});" />
				</td>
			</tr>
			<tr>
				<th>
					结束时间:
				</th>
				<td>
					<input type="text" id="endDate" name="endDate" class="text Wdate" value="[#if ad.endDate??]${ad.endDate?string("yyyy-MM-dd HH:mm:ss")}[/#if]" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', minDate: '#F{$dp.$D(\'beginDate\')}'});" />
				</td>
			</tr>
			<tr>
				<th>
					url:
				</th>
				<td>
					<input type="text" name="url" class="text" value="${ad.url}" maxlength="200" />
				</td>
			</tr>
			<tr>
				<th>
					排序:
				</th>
				<td>
					<input type="text" name="order" class="text" value="${ad.order}" maxlength="9" />
				</td>
			</tr>
            <tr>
                <th>
                    &nbsp;
                </th>
                <td>
                    <input type="submit" class="button" value="提交" />
                    <input type="button" class="button" value="返回" onclick="location.href='list.do'" />
                </td>
            </tr>
		</table>
	</form>
</body>
</html>